package actions;

/**
 * 
 * @author dernasherbrezon
 *
 */
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import tablemodels.RiskModel;
import utils.Risk;
import gui.MainFrame;

public class RiskFiller extends WizardStep
{
	private MainFrame parent;
	private RiskModel data;
	
	public RiskFiller(MainFrame parent)
	{	
		this.parent = parent;
		
		BoxLayout bl = new BoxLayout(this,BoxLayout.Y_AXIS);
		setLayout(bl);
		
		add(new JLabel("Возможные риски"));
		
		data = new RiskModel();
		JTable table = new JTable(data);
		table.getTableHeader().setReorderingAllowed(false);
		
		JScrollPane sp = new JScrollPane(table);
		add(sp);
	}
	
	@Override
	public void checkInputValues() throws Exception
	{
		data.checkCorrectValues();
	}

	@Override
	public void makeActions()
	{
		parent.risks.clear();
		for(int i=0;i<data.getRowCount();i++)
		{
			parent.risks.add(new Risk(i+1,(String)data.getValueAt(i,1)));
		}
	}

	@Override
	public void preShow()
	{
	}
}
